package com.px.auditRecord.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.px.framework.aes.AesSecurityParameter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.px.common.annotation.Log;
import com.px.common.core.controller.BaseController;
import com.px.common.core.domain.AjaxResult;
import com.px.common.enums.BusinessType;
import com.px.auditRecord.domain.ForRecordDrone;
import com.px.auditRecord.service.IForRecordDroneService;
import com.px.common.utils.poi.ExcelUtil;
import com.px.common.core.page.TableDataInfo;

/**
 * 我的设备Controller
 * 
 * @author WRJ
 * @date 2024-08
 */
@Api("我的设备")
@RestController
@RequestMapping("/forRecord/drone")
public class ForRecordDroneController extends BaseController
{
    @Autowired
    private IForRecordDroneService forRecordDroneService;

    /**
     * 查询我的设备列表
     */
    @ApiOperation("查询我的设备列表")
    @PreAuthorize("@ss.hasPermi('forRecord:drone:query')")
    @GetMapping("/list")
    @AesSecurityParameter(outEncode = true)
    public TableDataInfo list(ForRecordDrone forRecordDrone)
    {
        startPage();
        List<ForRecordDrone> list = forRecordDroneService.selectForRecordDroneList(forRecordDrone);
        return getDataTable(list);
    }

    /**
     * 导出我的设备列表
     */
    @ApiOperation("导出我的设备列表")
    @PreAuthorize("@ss.hasPermi('forRecord:drone:query')")
    @Log(title = "我的设备", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @AesSecurityParameter(outEncode = false)
    public void export(HttpServletResponse response, ForRecordDrone forRecordDrone)
    {
        List<ForRecordDrone> list = forRecordDroneService.selectForRecordDroneList(forRecordDrone);
        ExcelUtil<ForRecordDrone> util = new ExcelUtil<ForRecordDrone>(ForRecordDrone.class);
        util.exportExcel(response, list, "我的设备数据");
    }

    /**
     * 获取我的设备详细信息
     */
    @ApiOperation("获取我的设备详细信息")
    @PreAuthorize("@ss.hasPermi('forRecord:drone:query')")
    @GetMapping(value = "/{id}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(forRecordDroneService.selectForRecordDroneById(id));
    }

    /**
     * 新增我的设备
     */
    @ApiOperation("新增我的设备")
    @PreAuthorize("@ss.hasPermi('forRecord:drone:edit')")
    @Log(title = "我的设备", businessType = BusinessType.INSERT)
    @PostMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult add(@RequestBody ForRecordDrone forRecordDrone)
    {
        return toAjax(forRecordDroneService.insertForRecordDrone(forRecordDrone));
    }

    /**
     * 修改我的设备
     */
    @ApiOperation("修改我的设备")
    @PreAuthorize("@ss.hasPermi('forRecord:drone:edit')")
    @Log(title = "我的设备", businessType = BusinessType.UPDATE)
    @PutMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult edit(@RequestBody ForRecordDrone forRecordDrone)
    {
        return toAjax(forRecordDroneService.updateForRecordDrone(forRecordDrone));
    }

    /**
     * 删除我的设备
     */
    @ApiOperation("删除我的设备")
    @PreAuthorize("@ss.hasPermi('forRecord:drone:remove')")
    @Log(title = "我的设备", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(forRecordDroneService.deleteForRecordDroneByIds(ids));
    }

    /**
     * 查询个人备案设备
     */
    @ApiOperation("查询个人备案设备")
    @GetMapping(value = "/flightDrone")
    @AesSecurityParameter(outEncode = true)
    public TableDataInfo getFlightDrone(ForRecordDrone forRecordDrone)
    {
        startPage();
        List<ForRecordDrone> list = forRecordDroneService.selectForRecordDroneListByUserId(forRecordDrone);
        return getDataTable(list);
    }
}
